package web.JavaDate;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.10.09.11
 */
public class D1 {
@Test
@DisplayName("Java1.8Api日期")
    public void show(){
    //localDate
    var da=new Date();
    SimpleDateFormat df1=new SimpleDateFormat("yyyy-MM-dd");

    LocalDate d1=LocalDate.now();
    System.out.println(d1);
    System.out.printf("%tF%n",d1);
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
    LocalDate d2=LocalDate.of(1985,10,25);
    //LocalDate d3=LocalDate.of(da.getYear(),da.getMonth(),da.getDay());
    LocalDate d4=LocalDate.of(2022,02,10);
    System.out.println(d4.getDayOfWeek().getDisplayName(TextStyle.FULL,Locale.UK));
   // System.out.println(d2);
   // System.out.println(LocalDate.MIN);
    System.out.println(d2);
    DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy年MM月dd日");
    System.out.println(dtf.format(d2));
    System.out.println(d2.isLeapYear());
    System.out.println(d2.getDayOfWeek().name());
    System.out.println(d2.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINA));
    System.out.println(d2.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.CANADA));
    System.out.println(d2.getDayOfMonth());//25
    System.out.println(d2.getDayOfYear());//298
    System.out.println(d2.getChronology());
    var m=System.currentTimeMillis();
    System.out.println(m);
    System.out.println(String.format("%1$tF %1$tT",System.currentTimeMillis()));
   // int dd= Integer.parseInt(String.format("%1$tF %1$tT",m));
    final TimeZone timeZone = TimeZone.getTimeZone("GTM+8");
    Calendar c= Calendar.getInstance();
   //c.setTimeZone("GTM+8");
    c.setTimeInMillis(System.currentTimeMillis());
    int y=Calendar.YEAR;
    int month=Calendar.MONTH;
    int day=Calendar.HOUR_OF_DAY;
    int h=Calendar.HOUR_OF_DAY;
    System.out.println(h);
    int second=Calendar.SECOND;
    int minute=Calendar.MINUTE;

    c.getWeekYear();
    System.out.println(c.getWeekYear());
    LocalDateTime s=LocalDateTime.of(y,month,day-1,h,second,minute);
    System.out.println(dtf.format(s));
    System.out.println(s);
}
}
